<?xml version="1.0" encoding="utf-8"?>
<!-- DWXMLSource="cotizacion.xml" -->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
  <xsl:param name="ListaA"></xsl:param>
  <xsl:param name="ListaB"></xsl:param>
  <xsl:param name="ListaC"></xsl:param>
  <xsl:param name="ListaD"></xsl:param>
  <xsl:param name="IVA"></xsl:param>
  <xsl:decimal-format name="dollar"
decimal-separator="." grouping-separator=","/>
  <xsl:variable name="dominio" select="'http://localhost:50860/'"/>
  <xsl:template match="/ListaPrecios">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Documento Cotizacion</title>
    </head> <link href="http://localhost:50860/XMLCss/xslTrans.css" rel="stylesheet" type="text/css" />
    <body>
    
   

        
    <div id="ContenedorPrincipal">
      <div style="display:table;">
        <div id="header">Lista de precios 
        <xsl:if test="$IVA='true'">
          (Incluye I.V.A.)
        </xsl:if>
          <xsl:if test="$IVA='false'">
            (No Incluye I.V.A.)
          </xsl:if>
        </div>
        <div id="encabezado" style="margin-top:5px; float:left;  width:530px; font-size:12px;">
          <xsl:element name="img">
            <xsl:attribute name="src"> <xsl:value-of select="concat($dominio,'XMLCss/logomph.png')"/> </xsl:attribute>
            <xsl:attribute name="align">left</xsl:attribute>
          </xsl:element>
          AVENIDA BENITO JUAREZ SUR 78 <br/>
          CENTRO<br/>
          TIZAYUCA  HIDALGO, 43800<br/>
          779-796-4527<br />
          ventas@mphardware.com </div>
        <div style="float:left; width:300px; height:90px; display:table;">
          <table id="meta" >
            <tbody>
              <tr>
                <td class="meta-head">Fecha</td>
                <td><xsl:call-template name="FormatDate">
                    <xsl:with-param name="DateTime" select="@FechaGeneracion"/>
                    
                  </xsl:call-template></td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
      <div>
        <xsl:apply-templates select="Categoria"/>
        
        <xsl:for-each select="Categoria">
        </xsl:for-each>
      </div>

      <div id="header">
        Estos precios
        <xsl:if test="$IVA='true'">
          Incluyen I.V.A.
        </xsl:if>
        <xsl:if test="$IVA='false'">
          No Incluyen I.V.A.
        </xsl:if>
      </div>
      
    </div>
    </body>
    </html>
  </xsl:template>
  <xsl:template match="Categoria">
    <xsl:if test="count(Producto) > 0">
      <div >
        <div id="header" style="margin-bottom:0px; text-align:left;"><xsl:value-of select="@NombreCategoria"/> [<xsl:value-of select="@Id"/>]
        </div>
        <table id="meta-2" style="width:790px;text-transform:uppercase; font-size:10px;">
          <tbody>
            <tr>
              <td class="meta-head" style="width:80px;">Clave</td>
              <td class="meta-head" style="width:80px;">Linea</td>
              <td class="meta-head" style="width:80px;">Marca</td>
              <td class="meta-head" style="text-align:center;" width="*">Descripcion</td>
            
    <xsl:if test="$ListaA='true'">
              <td class="meta-head precio" style="width:55px;">Precio A</td>
            </xsl:if>
    <xsl:if test="$ListaB='true'">
              <td class="meta-head precio" style="width:55px;">Precio B</td>
            </xsl:if>
    <xsl:if test="$ListaC='true'">
              <td class="meta-head precio" style="width:55px;">Precio C</td>
            </xsl:if>
              <xsl:if test="$ListaD='true'">
                <td class="meta-head precio" style="width:55px;">Precio D</td>
              </xsl:if>
            </tr>
            <xsl:apply-templates select="Producto"/>
                        <xsl:for-each select="/Categoria/Producto">
            </xsl:for-each>
          </tbody>
        </table>
      </div>
    </xsl:if>
  </xsl:template>
  <xsl:template match="Producto">
    <tr>
      <td ><xsl:value-of select="@Clave"/></td>
      <td ><xsl:value-of select="@Linea"/></td>
      <td ><xsl:value-of select="@Marca"/></td>
      <td><xsl:value-of select="@Descripcion"/></td>

      <xsl:if test="$ListaA='true'">
      <td ><span class="price">$<xsl:value-of select="format-number(@Precio1, '#,##0.00','dollar')"/></span></td>
      </xsl:if>
      <xsl:if test="$ListaB='true'">
      <td ><span class="price">$<xsl:value-of select="format-number(@Precio2, '#,##0.00','dollar')"/></span></td>
      </xsl:if>
      <xsl:if test="$ListaC='true'">
      <td ><span class="price">$<xsl:value-of select="format-number(@Precio3, '#,##0.00','dollar')"/></span></td>
      </xsl:if>
      <xsl:if test="$ListaD='true'">
      <td ><span class="price">$<xsl:value-of select="format-number(@Precio4, '#,##0.00','dollar')"/></span></td>
      </xsl:if>
    </tr>
  </xsl:template>
  <xsl:template name="FormatDate">
    <xsl:param name="DateTime" />
    <xsl:variable name="year" select="substring($DateTime,1,4)" />
    <xsl:variable name="month-temp" select="substring-after($DateTime,'-')" />
    <xsl:variable name="month" select="substring-before($month-temp,'-')" />
    <xsl:variable name="day-temp" select="substring-after($month-temp,'-')" />
    <xsl:variable name="day" select="substring($day-temp,1,2)" />
    <xsl:variable name="time" select="substring-after($DateTime,'T')" />
    <xsl:variable name="hh" select="substring($time,1,2)" />
    <xsl:variable name="mm" select="substring($time,4,2)" />
    <xsl:variable name="ss" select="substring($time,7,2)" />
    
    <!-- Long DATE FORMAT -->
    
    <xsl:value-of select="$day"/><xsl:value-of select="' de '"/><!--January -->
    <!--January 12 -->
    <xsl:choose>
      <xsl:when test="$month = '1' or $month= '01'">
        Enero
      </xsl:when>
      <xsl:when test="$month = '2' or $month= '02'">
        Febrero
      </xsl:when>
      <xsl:when test="$month= '3' or $month= '03'">
        Marzo
      </xsl:when>
      <xsl:when test="$month= '4' or $month= '04'">
        Abril
      </xsl:when>
      <xsl:when test="$month= '5' or $month= '05'">
        Mayo
      </xsl:when>
      <xsl:when test="$month= '6' or $month= '06'">
        Junio
      </xsl:when>
      <xsl:when test="$month= '7' or $month= '07'">
        Julio
      </xsl:when>
      <xsl:when test="$month= '8' or $month= '08'">
        Agosto
      </xsl:when>
      <xsl:when test="$month= '9' or $month= '09'">
        Septiembre
      </xsl:when>
      <xsl:when test="$month= '10'">
        Octubre
      </xsl:when>
      <xsl:when test="$month= '11'">
        Noviembre
      </xsl:when>
      <xsl:when test="$month= '12'">
        Diciembre
      </xsl:when>
    </xsl:choose>
    <xsl:value-of select="' de'"/><!--January 12,-->
    <xsl:value-of select="' '"/><!--January 12, -->
    <xsl:value-of select="$year"/><!--January 12, 2001-->
    <!--
    <xsl:value-of select="' a las '"/><xsl:value-of select="$hh"/><xsl:value-of select="':'"/><xsl:value-of select="$mm"/><xsl:value-of select="':'"/><xsl:value-of select="$ss"/><xsl:value-of select="' (GMT) '"/>-->
    <!-- END: Long DATE FORMAT -->
    
  </xsl:template>
</xsl:stylesheet>